package org.me.app.student;

import java.util.ArrayList;

import android.app.ListActivity;
import android.content.Intent;

import android.os.Bundle;
import android.os.Parcelable;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

import org.me.*;
import org.me.app.R;
import org.me.app.R.layout;
import org.me.app.instructor.AnnListActivity;
import org.me.bean.Announcement;
import org.me.bean.CourseSchedule;
import org.me.bean.Student;
import org.me.bean.StudentData;

public class ScheduleListActivity extends ListActivity {

	
	private ArrayList<Announcement> annList = new ArrayList<Announcement>();
	private ArrayList<CourseSchedule> courseList = new ArrayList<CourseSchedule>();
	private Student student = new Student();
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		Bundle b = getIntent().getExtras();
		courseList = b.getParcelableArrayList("CourseList");
		student = b.getParcelable("Student");
		
		setListAdapter(new ArrayAdapter<CourseSchedule>(this, R.layout.courseinfor,
				courseList));

		ListView lv = getListView();
		lv.setTextFilterEnabled(true);
		lv.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				
				Intent i = new Intent(getApplicationContext(), 
						org.me.app.student.AnnouncementListActivity.class);
				i.putParcelableArrayListExtra("AnnList", 
						(ArrayList<? extends Parcelable>) courseList.
						get(position).
						getAnnList());
				i.putExtra("Student", student);
				i.putExtra("CourseScheduleId", courseList.get(position).getCourseScheduleId());
				startActivity(i);

			}
		});

	}

}
